package com.example.util;

import com.example.entity.MicroResponse;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.springframework.http.ResponseEntity;

/**
 * @program: microservice
 * @description:
 * @author: Aprilies
 * @create: 2024-09-11 17:46
 **/

public class MicroResponseUtils {
    // 成功
    public static <T> MicroResponse<T> success(T data){
        MicroResponse<T> response = new MicroResponse<>();
        response.setCode(0);
        response.setMessage("success");
        response.setData(data);
        return response;
    }

    // 错误
    public static <T> MicroResponse<T> error(String message){
        MicroResponse<T> response = new MicroResponse<>();
        response.setCode(1);
        response.setMessage(message);
        return response;
    }
}
